package com.zlzxm.shoesmarket.view.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.zlzxm.shoesmarket.R;
import com.zlzxm.shoesmarket.util.ZViewHelp;
import com.zlzxm.shoesmarket.view.adapter.ADOutNote;
import com.zlzxm.shoesmarket.viewmodel.VMInNote;
import com.zlzxm.shoesmarket.viewmodel.VMOutNote;

/**
 * CREATE BY zlzxm ON 4/16/21
 */
public class FMOutNote extends BaseFragment{


    RecyclerView recyclerView;

    VMOutNote vmOutNote;

    ADOutNote adOutNote = new ADOutNote();


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.layout_list,container,false);
    }

    @Override
    protected void initView(@NonNull View view, @NonNull Bundle savedInstanceState) {
        super.initView(view, savedInstanceState);
        recyclerView = ZViewHelp.findById(view,R.id.list);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    }

    @Override
    protected void initViewModel() {
        super.initViewModel();
        vmOutNote = new ViewModelProvider(this)
                .get(VMOutNote.class);

        vmOutNote.getLiveInNote().observe(this, adOutNote::setList);
    }


    @Override
    protected void initData() {
        super.initData();
        recyclerView.setAdapter(adOutNote);
        vmOutNote.requestData();
    }
}
